package com.mynature.booking.model;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


import com.mynature.booking.database.DatabaseManager;
import com.mynature.booking.manager.QueryInfo;

public class Login extends JFrame {

	public static Login frame= new Login();
	private static final long serialVersionUID = -9062872616984578993L;
	private JPanel contentPane;
	private JTextField textField_1;
    public static int i;

	
	/**
	 * Create the frame.
	 */
	public Login() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 413, 269);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblPersonalnumber = new JLabel("PersonalNumber");
		lblPersonalnumber.setBounds(72, 63, 101, 32);
		contentPane.add(lblPersonalnumber);
		
		textField_1 = new JTextField();
		textField_1.setBounds(183, 69, 158, 21);
		contentPane.add(textField_1);
		textField_1.setColumns(10);
        textField_1.getText();
        
        
		
		JButton btnConfirm = new JButton("Confirm");
		btnConfirm.setBounds(89, 122, 93, 23);
		contentPane.add(btnConfirm);
		btnConfirm.addActionListener(new ActionListener() {
			
		public void actionPerformed(ActionEvent e) {
			    i=Integer.parseInt(textField_1.getText());
			    DatabaseManager.getInstance().queryPersonByPersonalNumber(i);
				setVisible(false);
				QueryInfo.frame.setVisible(true);
			
			}
		});
		
		JButton btnCancel = new JButton("Back");
		btnCancel.setBounds(233, 122, 93, 23);
		contentPane.add(btnCancel);
        btnCancel.addActionListener(new ActionListener() {
			

			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				LogAndCreate .frame.setVisible(true);
				
				
			}
		});
		
		JLabel lblEnterYourNumberaccount = new JLabel("Enter your PersonalNumber here");
		lblEnterYourNumberaccount.setForeground(Color.RED);
		lblEnterYourNumberaccount.setBounds(89, 180, 304, 15);
		contentPane.add(lblEnterYourNumberaccount);
	}

	
	}

